<template>
	<view>
		<cu-custom bgColor="bg-white" :isBack="true">
			<block slot="back">返回</block>
			<block slot="content">我的订单</block>
		</cu-custom>
		<view class="bcf pad3 shadow1 round3 mar5 c12 " v-if="$com.isbool(order)">
			<view class="flex-r flex-start pad5 bdbda">
				<view class="">货物描述：</view>
				<view class="flex1 c11">{{order.title}}</view>
			</view>
			<view class="flex-r flex-start pad5 bdbda">
				<view class="">发货地址：</view>
				<view class="flex1 c11">{{order.startAddress}}</view>
				<view class="ripple text-green pad2" @click="showLoaction(order.startLat,order.startLon)">
					<text class="fa fa-location-arrow fa-2x"></text>
				</view>
			</view>
			<view class="flex-r flex-start pad5 bdbda">
				<view class="">收货地址：</view>
				<view class="flex1 c11">{{order.endAddress}}</view>
				<view class="ripple text-green pad2" @click="showLoaction(order.endLat,order.endLon)">
					<text class="fa fa-location-arrow fa-2x"></text>
				</view>
			</view>
			<view class="flex-r flex-start pad5 bdbda">
				<view class="">联 系 人 ：</view>
				<view class="flex1 c11">{{order.contact}}</view>
			</view>
			<view class="flex-r flex-start pad5 bdbda">
				<view class="">联系电话：</view>
				<view class="flex1 c11">{{order.phone}}</view>
			</view>
			<view class="flex-r flex-start pad5 bdbda">
				<view class="">车辆类型：</view>
				<view class="flex1 c11">
					<view>{{order.goods.name}}</view>
					<view>{{order.goods.intro}}</view>
				</view>
			</view>
			<view class="flex-r flex-start pad5 bdbda">
				<view class="">车辆长度：</view>
				<view class="flex1 c11">
					<view>{{order.carType.name}}</view>
					<view>{{order.carType.intro}}</view>
				</view>
			</view>
			<view class="flex-r flex-start pad5 bdbda">
				<view class="">装卸类型：</view>
				<view class="flex1 c11">
					<view>{{order.loadType.name}}</view>
					<view>{{order.goods.intro}}</view>
				</view>
			</view>
			<view class="flex-r flex-start pad5 bdbda">
				<view class="">货物类型：</view>
				<view class="flex1 c11">
					<view>{{order.car.name}}</view>
					<view>{{order.car.intro}}</view>
				</view>
			</view>
			<view class="flex-r flex-start pad5 bdbda">
				<view class="">订单编号：</view>
				<view class="flex1 c11">{{order.sn}}</view>
				<view class="cu-btn" @click="copy(order.sn)">复制</view>
			</view>
			<view class="flex-r flex-start pad5 bdbda">
				<view class="">创建时间：</view>
				<view class="flex1 c11">{{$com.str2time(order.createAt)}}</view>
			</view>

			<view class="flex-r flex-start pad5 bdbda">
				<view>订单状态：</view>
				<view class="flex1 c11">
					{{order.status == 0?'待处理':''}}
					{{order.status == 1?'已处理':''}}
					{{order.status == 2?'已取消':''}}
					{{order.status == 9?'已完成':''}}
					{{order.status == 10?'已返利':''}}
				</view>
			</view>

		</view>
		<view class="mar5" v-if="order.status == 0">
			<view class="round pad5 fs12 tac bg-red ripple" @click="cancelOrder">取消订单</view>
		</view>


	</view>
</template>

<script>
	import api from '../../../static/js/api.js'
	import com from '../../../static/js/com.js'
	import win from '../../../static/js/win.js'
	export default {
		data() {
			return {
				id: '',
				order: {}
			}
		},
		methods: {
			showLoaction(lat, lon) {
				uni.openLocation({
					latitude: lat,
					longitude: lon,
					success: function() {
						console.log('success');
					}
				});
			},
			cancelOrder() {
				api.delete("/api/wuliuOrders/" + this.id, {}, function(res) {
					console.log(res)
					if(res.s == 1){
						win.goback()
					}
				})
			},
			copy(sn){
				uni.setClipboardData({
					data: sn
				});
			}
		},
		onLoad(option) {
			let _this = this
			console.log(option)
			this.id = option.id
			this.$api.get("/api/wuliuOrders/" + this.id, {}, function(res) {
				_this.order = res.d
				console.log(res)
			})
		}
	}
</script>

<style>

</style>
